package com.ytc.web.interceptor;

import com.ytc.commons.model.vo.AuthInfo;

//操作threadlocal的工具类
public class AuthInfoHolder {
    //定义ThreadLocal
    private static ThreadLocal<AuthInfo> tl = new ThreadLocal<>();
    //存入ThreadLocal
    public static void setAuthInfo(AuthInfo info) {
        tl.set(info);
    }
    //从ThreadLocal取出
    public static AuthInfo getAuthInfo() {
        return tl.get();
    }
    //删除ThreadLocal数据
    public static void remove() {
        tl.remove();
    }

    public static Long getUserId() {
        return tl.get().getUid();
    }

    public static Long getCompanyId() {
        if(tl.get() != null) {
            return tl.get().getCompanyId();
        }else {
            return null;
        }

    }
}
